<?php
class Exts_Views_Helpers_Elements extends Zend_View_Helper_Abstract {
    
    public function elements() 
    {
        return $this;
    }


    /**
     * check if your form take any errors,
     * @param Zend_Form_Element $element
     * @return boolean true|false
     */
    public function hasErrors( $element )
	{
        $output = '';
        if( count( $element->getErrorMessages() ) ){
            return true;
        } elseif( count( $element->getErrors() ) ) {
            return true;
        }
		return false;
	}

    /**
     * Render errors in your form in string mode
     * @param Zend_Form_Element $element
     * @param string $init string after the error message for example <li>
     * @param string $end string before the error message for example </li>
     * @return string $output
     */
	public function showErrors( $element, $init = NULL, $end = NULL )
	{
		$output = '';
		if( count( $element->getErrorMessages() ) ){
			foreach( $element->getErrorMessages() as $err ){
				$output .= $init . $err . $end . ' ';
			} 
		} elseif( count( $element->getErrors() ) ) {
			foreach( $element->getErrors() as $err ){
				$output .= $init . $err . $end. ' ';
			}
		}
		return $output;
	}
	
}
